The Dreamweaver JavaScript API > Deprecated functions > dreamweaver.nodeToOffsets()

 

dreamweaver.nodeToOffsets()

Availability

Dreamweaver 2.0, deprecated in 3.0 in favor of dom.nodeToOffsets().

Description

Gets the position of a specific node in the DOM tree, expressed as byte offsets into the document's HTML source code.

Arguments

node

node must be a tag, comment, or range of text that is a node in the tree returned by dreamweaver.getDocumentDOM().

Returns

An array containing two integers. The first integer is the byte offset of the beginning of the tag, text, or comment; the second integer is the byte offset of the end of the node.

Example

The following code selects the first image object in the current document:

var theDOM = dreamweaver.getDocumentDOM("document");
var theImg = theDOM.images[0];
var offsets = dom.nodeToOffsets(theImg);
dom.setSelection(offsets[0], offsets[1]);